package me.zhengjie.modules.management.rest.admin;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.management.domain.MrMaterialDtl;
import me.zhengjie.modules.management.domain.Pageable;
import me.zhengjie.modules.management.service.MrMaterialDtlService;
import me.zhengjie.modules.management.service.dto.MrMaterialDtlCriteria;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: eladmin
 * @description: 材料控制层
 * @author: ming.cao
 * @create: 2020-12-09 10:17
 **/
@RestController
@RequiredArgsConstructor
@Api(tags ="MR:物资材料管理")
@RequestMapping("/api/mrMaterial")
public class MrMaterialDtlController {
    private final MrMaterialDtlService mrMaterialDtlService;

    @GetMapping
    @Log("获取物资材料数据")
    @ApiOperation("获取物资材料数据")
    public Object getAllList( MrMaterialDtlCriteria criteria,Pageable pageable){
        return mrMaterialDtlService.getAllList(criteria,pageable);
    }

    @PostMapping
    @Log("新增物资材料数据")
    @ApiOperation("新增物资材料数据")
    public void addMrMaterialDtl(@RequestBody MrMaterialDtl mrMaterialDtl){
        mrMaterialDtlService.addMrMaterialDtl(mrMaterialDtl);
    }

    @PutMapping
    @Log("更新物资材料数据")
    @ApiOperation("更新物资材料数据")
    public void updateMrMaterialDtl( @RequestBody MrMaterialDtl mrMaterialDtl){
        mrMaterialDtlService.updateMrMaterialDtl(mrMaterialDtl);
    }

    @DeleteMapping
    @Log("删除物资材料数据")
    @ApiOperation("删除物资材料数据")
    public void delMaterialDtl( @RequestBody List<Integer> ids){
        mrMaterialDtlService.delMrMaterialDtl(ids);
    }

    @GetMapping("/getDtlById")
    @Log("获取id获取物资材料数据")
    @ApiOperation("获取id获取物资材料数据")
    public Object getMaterialDtlById(Integer id){
        return mrMaterialDtlService.getMrMaterialDtlById(id);
    }

}
